package fun.hijklmn.magic.idGenerator.server.service.impl;

import com.xfvape.uid.UidGenerator;
import fun.hijklmn.magic.idGenerator.common.enums.ServerTypeEnum;
import fun.hijklmn.magic.idGenerator.common.pojo.WorkerNode;
import fun.hijklmn.magic.idGenerator.server.dao.WorkerNodeDao;
import fun.hijklmn.magic.idGenerator.server.service.WorkerNodeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * DB WorkerID Assigner for UID Generator 服务实现类
 * </p>
 *
 * @author zsl
 * @since 2021-07-12
 */
@Service
public class WorkerNodeServiceImpl extends ServiceImpl<WorkerNodeDao, WorkerNode> implements WorkerNodeService {

    @Autowired
    private UidGenerator uidGenerator;

    @Override
    public String get(ServerTypeEnum serverTypeEnum) {
        return serverTypeEnum.shortCode() + uidGenerator.getUID();
    }

}
